package com.jm.service.impl.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jm.common.bean.base.PageParam;
import com.jm.common.bean.base.PageVO;
import com.jm.common.conf.mybatis.EnhanceServiceImpl;
import com.jm.mapper.system.PlMapper;
import com.jm.model.system.Pl;
import com.jm.service.i.system.PlService;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Collection;

/**
 * @author kong
 * @since 2023-06-25
 */
@Service
public class PlServiceImpl extends EnhanceServiceImpl<PlMapper, Pl> implements PlService {

    @Autowired
    public PlServiceImpl(RedisTemplate<String, Object> redis, RedissonClient redissonClient) {
        super(redis, redissonClient);
    }

    @Override
    public PageVO<Pl> page(PageParam param) {
        return PageVO.convert(page(new Page<>(param.getCurrent(), param.getSize()), new LambdaQueryWrapper<>()));
    }

    public static void main(String[] args) {
        LocalDate start = LocalDate.of(2017, 10, 12);
        System.out.println(LocalDate.now().toEpochDay() - start.toEpochDay());
    }

    @Override
    public boolean updateBatchById(Collection<Pl> entityList) {
        boolean flag = this.baseMapper.enhanceBatchUpdate(entityList) > 0;
        return flag;
    }
}